const os = require("os");

module.exports = function () {
  const interfaces = os.networkInterfaces(); // 获取所有网络接口的信息

  for (let interface in interfaces) {
    if (!interfaces.hasOwnProperty(interface)) continue;
    for (const ifaceInfo of interfaces[interface]) {
      const { family, internal, address } = ifaceInfo;
      if (family === "IPv4" && !internal && address !== "127.0.0.1") {
        return address;
      }
    }
  }
  return "";
};
